<template>
  <div class="page-container">
    <el-container>
      <el-aside width="200px">
        <div class="item">
          <el-table
            ref="singleTable"
            :data="tableData"
            height="600"
            highlight-current-row
            style="width: 100%"
          >
            <el-table-column property="value" label="商品配置管理" width="200">
              <template slot-scope="scope">
                  <el-button type="primary" plain size="medium" @click="getClassProInfo(scope.row)">{{scope.row.name}}</el-button>
            </template>  
            </el-table-column>
          </el-table>
        </div>
      </el-aside>
      <el-main>
        <el-tabs type="border-card">
            <el-tab-pane>
                <span slot="label"><i class="el-icon-setting"></i> 商品配置</span>
                <div class="active tab-pane container" id="setting" align="center" style="width: 100%;height:950px;overflow-y: auto">
                    <template>
                        <iframe align="center" id="contentUrl" :src="src" width="100%" height="100%" frameborder="no" srcolling="no" style="overflow-y: auto"></iframe>
                    </template>
                </div>
            </el-tab-pane>
            <el-tab-pane>
                <span slot="label"><i class="el-icon-sold-out"></i> 配置预览</span>
                <div class="tab-pane" id="user" align="center" style="width: 100%;height:950px;overflow-y: auto">
                    <template>
                        <iframe align="center" id="contentShowUrl" @tab-click="handleClick" :src="src2" width="100%" height="100%" frameborder="no" srcolling="no" style="overflow-y: auto"></iframe>
                    </template>
                </div>
            </el-tab-pane>
        </el-tabs>
      </el-main>
    </el-container>

    <!--新增编辑界面-->
    <el-dialog
      :title="'新增'"
      width="25%"
      :visible.sync="editDialogVisible"
      :close-on-click-modal="false"
    >
      <el-form
        :model="dataForm"
        label-width="80px"
        :rules="dataFormRules"
        ref="dataForm"
        :size="size"
      >
        <el-form-item label="ID" prop="id" v-if="false">
          <el-input v-model="dataForm.id" :disabled="true" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="规格名称" prop="name">
          <el-input v-model="dataForm.name" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="规格编码" prop="code">
          <el-input v-model="dataForm.code" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="排序" prop="sortno">
          <el-input v-model="dataForm.sortno" auto-complete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button :size="size" @click.native="editDialogVisible = false">{{$t('action.cancel')}}</el-button>
        <el-button
          :size="size"
          type="primary"
          @click.native="submitForm"
          :loading="editLoading"
        >{{$t('action.submit')}}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import CyTable from "@/views/Core/CyTable";
import KtButton from "@/views/Core/KtButton";
import { format } from "@/utils/datetime";
import TableColumnFilterDialog from "@/views/Core/TableColumnFilterDialog";
export default {
  components: {
    CyTable,
    KtButton,
    TableColumnFilterDialog
  },
  data() {
    return {
      size: "small",
      filters: {
        t: "productSpecs",
        sql: "querySpecsShopList",
        sqlCount: "querySpecsShopListCount",
        shop_id: ""
      },
      indexId:'1',
      src:'',
      src2:'',
      columns: [
        { prop: "id", label: "编号", minWidth: 50 },
        { prop: "specs_name", label: "类型id", minWidth: 100 },
        { prop: "name", label: "规格名称", minWidth: 100 },
        { prop: "code", label: "规格编码", minWidth: 80 },
        { prop: "shop_name", label: "商铺名称", minWidth: 120 },
        { prop: "sortno", label: "排序", minWidth: 100 }
      ],
      shopIds: [{ value: "", label: "请选择" }],
      shop_id:'',
      filterColumns: [],
      tableData:[{id:1,name:'限时购'},{id:2,name:'居家生活'},{id:3,name:'美妆护肤'},{id:4,name:'数码家电'},{id:5,name:'母婴保健'},{id:6,name:'美食酒水'},
      {id:7,name:'个护清洁'},{id:8,name:'切换图'},{id:9,name:'好物甄选'}],
      pageRequest: { pageNum: 1, pageSize: 10 },
      pageResult: {},
      editDialogVisible: false, // 新增编辑界面是否显示
      editLoading: false,
      editLoading: false,
      dataFormRules: {
        name: [{ required: true, message: "请输入规格名称", trigger: "blur" }],
        code: [{ required: true, message: "请输入规格编码", trigger: "blur" }],
        sortno: [{ required: true, message: "请输入排序", trigger: "blur" }]
      },
      // 新增编辑界面数据
      dataForm: {
        t: "productSpecs",
        name: "",
        code: "",
        sortno: "",
        specs_id: "",
        shop_id: "",
        method: "saveSpecsShopInfo"
      }
    };
  },
  methods: {
    getClassProInfo: function(data) {
        console.log(data);
        this.indexId = data.id;
        this.src = 'static/index/index'+this.indexId+'.html';
        this.src2 = 'static/showIndex/index'+this.indexId+'.html';
    },
    handleClick: function(){

    },
    // 时间格式化
    dateFormat: function(row, column, cellValue, index) {
      return format(row[column.property]);
    },

    resetForm(formName) {
      if (this.$refs[formName] != undefined) {
        this.$refs[formName].resetFields();
      }
    },

    // 处理表格列过滤显示
    displayFilterColumnsDialog: function() {
      this.$refs.tableColumnFilterDialog.setDialogVisible(true);
    },
    // 处理表格列过滤显示
    handleFilterColumns: function(data) {
      this.filterColumns = data.filterColumns;
      this.$refs.tableColumnFilterDialog.setDialogVisible(false);
    },
    // 处理表格列过滤显示
    initColumns: function() {
      var temp = [];

      $.each(this.columns, function(key, val) {
        temp.push(val);
      });
      this.filterColumns = temp;
    },
    //列表下载
    downloadExcel() {
      this.$confirm("确定下载列表文件?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let filename = "系统参数下载";
          this.$refs.CyTable.exportData(
            this.filters,
            this.filterColumns,
            filename
          );
        })
        .catch(() => {});
    }
  },
  mounted() {
    this.initColumns();
    var this_ = this;
    this.utils.request.queryUserList({ t: "shop" }, function(data) {
      if (null != data.data) {
        for (var i = 0; i < data.data.length; i++) {
          var obj = {};
          obj.value = data.data[i].id;
          obj.label = data.data[i].name;
          this_.shopIds.push(obj);
        }
      }
    });
    // $("#contentUrl").attr("src",'https://www.baidu.com');
    this.src = 'static/index/index'+this.indexId+'.html';
  }
};
</script>

<style scoped>
.item {
  padding-top: 10px; 
  overflow-y: auto!important;
}
</style>

